package com.cgy.utils.jmx.jvm.pid;

import com.cgy.utils.jmx.IJvmInfoFactory;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author CHTK
 */
public class PidFactory extends IJvmInfoFactory {

    @Override
    public void status() {
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        String pid = runtime.getName().split("@")[0];
        put("pid", pid, "PID");
    }

    @Override
    public Map<String, String> fields() {
        return new HashMap<String, String>() {
            {
                put("os.name", "操作系统的名称");
                put("os.version", "操作系统的架构");
                put("os.arch", "操作系统的版本");
            }
        };
    }


}
